/*!
    \copyright  Copyright (c) 2024 - 2025 Qualcomm Technologies International, Ltd.
                All Rights Reserved.
                Qualcomm Technologies International, Ltd. Confidential and Proprietary.
    \file
    \defgroup   relay_group relay module for stereo audio Channel rendering
    \ingroup    bt
    \brief      This module is used to control stream relay (stereo/mono stream) based on usecase and codec between the peer buds.
*/

#ifndef RELAY_CONTROL_H_
#define RELAY_CONTROL_H_

#include "audio_lea_types.h"
#ifdef USE_SYNERGY
#include "bap_server_prim.h"
#else
#include "bap_server.h"
#endif

#ifdef INCLUDE_MIRRORING

/*! \brief Defines the type of relay setting to use */
typedef enum
{
    relay_mode_disabled,                         /* No relay, Based on location, left only or right only data rendered locally */
    relay_mode_enabled                           /* Relay both left and right audio channels, i.e. rendered both channels locally */
} relay_mode_t;

/*! \brief Bits to set for each of the relayed audio usecases */
typedef enum
{
    relay_usecase_none             = (0 << 0),
    relay_usecase_non_media        = (1 << 0),
    relay_usecase_media            = (1 << 1),
    relay_usecase_voice            = (1 << 2),
    relay_usecase_gaming           = (1 << 3),
    relay_usecase_live             = (1 << 4)
} relay_usecase_t;

/*! \brief Defines relay codec type */
typedef enum
{
    relay_codec_type_lc3,
    relay_codec_type_aptx_adaptive_r3,
    relay_codec_type_max
} relay_codec_type_t;

/*! \brief API to Get relay usecase mask for the specified codec
 *
 *  \param codec_type codec for which the relay setting is to be retrieved.
 *
 *  \return Usecase mask for the specified relay codec type. \ref relay_usecase_t.
 */
uint32 RelayControl_GetRelayConfig(relay_codec_type_t codec_type);

/*! \brief API to enable stream relay between peer for a given usecase and codec type
 *
 *  \param usecases Usecase mask \ref relay_usecase_t.
 *  \param codec_type codec for which the relay setting is to be applied.
 *
 *  \return TRUE, if Relay can be enabled, FALSE otherwise
 *
 *    NOTE: 1. This API needs to be called on each of the earbuds
 *          2. API is not to be called while indicated usecase is inprogress
 */
bool RelayControl_EnableRelay(uint32 usecases, relay_codec_type_t codec_type);

/*! \brief API to disable relay for a given usecase and codec type
 *
 *  \param usecases Usecase mask \ref relay_usecase_t.
 *  \param codec_type codec for which the relay setting is to be applied.
 *
 *  \return TRUE, if Relay is disabled, FALSE otherwise
 *
 *    NOTE: 1. This API needs to be called on each of the earbuds
 *          2. API is not to be called while indicated usecase is inprogress
 */
bool RelayControl_DisableRelay(uint32 usecases, relay_codec_type_t codec_type);

/*! \brief Get relay mode for the given relay usecase and codec
 *
 *  \param usecase Usecase mask \ref relay_usecase_t.
 *  \param codec_type relay Codec for which relay mode is to be retrieved.
 *
 *  \return relay_mode_t Relay mode
 */
relay_mode_t RelayControl_GetRelayMode(relay_usecase_t usecase, relay_codec_type_t codec_type);

/*! \brief Is relay enabled for given usecase and codec
 *
 *  \param usecase Usecase \ref relay_usecase_t.
 *  \param codec_type Codec used for the usecase.
 *
 *  \return TRUE if Relay is Enabled, FALSE otherwise
 */
#define RelayControl_IsRelayEnabled(usecase, codec_type) (RelayControl_GetRelayMode(usecase, codec_type) != relay_mode_disabled)

/*! \brief Utility to convert the LE audio codec to relay codec type
 *
 *  \param appKymeraLeAudioCodec LE audio codec
 *
 *  \return relay_codec_type_t relay codec type for LE audio codec
*/
relay_codec_type_t RelayControl_GetRelayCodecTypeFromLeAudioCodec(appKymeraLeAudioCodec le_audio_codec);

/*! \brief Utility to convert the LE audio context to relay usecase
 *
 *  \param le_audio_context LE audio context
 *
 *  \return relay_usecase_t relay usecase for the LE audio context
*/
relay_usecase_t RelayControl_GetUsecaseFromLeAudioContext(AudioContextType le_audio_context);

#endif /* INCLUDE_MIRRORING */

#endif /* RELAY_CONTROL_H_ */

